Merged
Conversation
Contributor
There was a problem hiding this comment.
Reviewed the change to support multiline custom guidelines. Great move switching to the multi-line $GITHUB_OUTPUT block format — this will prevent issues with newlines.
I have one small, high-confidence improvement suggestion to make this even safer and more robust.
🤖 Automated review complete. Please react with 👍 or 👎 on the individual review comments to provide feedback on their usefulness.
| if [ -n "$CUSTOM_GUIDELINES" ]; then | ||
| echo "context=$(jq -n --arg guidelines "$CUSTOM_GUIDELINES" '{custom_guidelines: $guidelines}')" >> $GITHUB_OUTPUT | ||
| echo 'context<<EOF' >> $GITHUB_OUTPUT | ||
| echo "$(jq -n --arg guidelines "$CUSTOM_GUIDELINES" '{custom_guidelines: $guidelines}')" >> $GITHUB_OUTPUT |
Contributor
There was a problem hiding this comment.
Nice switch to the multi-line output format. To further harden this and avoid any quoting/command-substitution pitfalls, consider:
- Avoiding command substitution so you don’t lose trailing newlines and to keep very long outputs safe
- Quoting
$GITHUB_OUTPUTin case the path ever contains spaces - Using a slightly more unique delimiter than
EOF
Example rewrite:
{
{
echo 'context<<GH_EOF'
jq -n --arg guidelines "$CUSTOM_GUIDELINES" '{custom_guidelines: $guidelines}'
echo 'GH_EOF'
} >> "$GITHUB_OUTPUT"
}This writes jq’s output directly without $(...), keeps formatting intact, and quotes the output file path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix handling of multiline custom guidelines in the GitHub Action
$GITHUB_OUTPUT(context<<EOF ... EOF) soCUSTOM_GUIDELINESvalues with newlines are preserved intact.jqas{ "custom_guidelines": <string> }, so downstream consumers remain unchanged.{}whenCUSTOM_GUIDELINESis unset.Impact
🤖 This description was generated automatically. Please react with 👍 if it's helpful or 👎 if it needs improvement.